import { baseUrlConfig } from '@/config/config';
import request from '@/utils/request'

const bastPath = baseUrlConfig.processBaseUrl

export interface AppendGoodsItem {
  goodsName: string;
  goodsType?: string;
  pickUpTime?: string;
  timeLimit?: number;
  timeLimitUnit?: string;
  goodsLimitTime?: string;
  pickUpName?: string;
  pickUpPhone?: string;
  pickUpTerminal?: string;
  pickUpPlace?: string;
  depositTerminal?: string;
  depositPlace?: string;
  files?: Array<{
    enclosureContent: string,
    enclosureName: string,
    enclosureSuffix: string,
    resourceAddress: string,
    enclosureCode: string
  }>;
  creator: {
    id: string;
    name: string;
    organId: string;
    organName: string;
  }
}

export interface AcceptGoodsReq {
  taskId: string
  content: {
    creator: {
      id: string
      name: string
      organId: string
      organName: string
    }
  }
  createTime?: string
}

export interface ReceiveGoodsItem {
  regId: string
  taskId: string
  receiveName: string
  receiveNo?: string
  receivePhone: string
  receiveTime: string
  remarks: string
  creator: {
    id: string
    name: string
    organId: string
    organName: string
  },
  createTime?: string
}

// 捡拾物品详情
export const pickUpGoodsDetail = (data: { regId: string, taskId: string }) => {
  return request({
    url: bastPath + '/lose/goodsReg/detail',
    method: 'post',
    data
  })
}

// 分页查询捡拾物品
export const goodsReg = (data: ListParams) => {
  return request({
    url: bastPath + '/lose/goodsReg/find/page',
    method: 'post',
    data
  })
}

// 查询所有捡拾物品
export const getAllGoodsReg = (data: any) => {
  return request({
    url: bastPath + '/lose/goodsReg/find',
    method: 'post',
    data
  })
}

// 捡拾物品登记
export const pickUpGoodsAppend = (data: AppendGoodsItem) => {
  return request({
    url: bastPath + '/lose/goodsReg/append',
    method: 'post',
    data
  })
}

// 领取捡拾物品
export const pickUpGoodsReceive = (data: ReceiveGoodsItem) => {
  return request({
    url: bastPath + '/lose/goodsReg/receive',
    method: 'post',
    data
  })
}
// 接收物品
export const acceptPickPuGoods = (data: Array<AcceptGoodsReq>) => {
  return request({
    url: bastPath + '/lose/goodsReg/accept/list',
    method: 'post',
    data
  })
}
